﻿namespace hedefgrup.reports.renault.definitions
{
    using hedefgrup.reports.renault;
    using hedefgrup.reports.renault.implementation;
    using System;
    using System.Collections.Generic;
    using System.Xml;

    public class questionDefinition : xmlNodeBasedClass
    {
        public SortedList<int, optionDefinition> optionDefinitions;
        private dataCache sourceData;

        public questionDefinition(dataCache sourceData, XmlNode questionNode) : base(questionNode)
        {
            this.optionDefinitions = new SortedList<int, optionDefinition>();
            this.sourceData = sourceData;
            foreach (XmlNode node in questionNode.ChildNodes)
            {
                optionDefinition definition = new optionDefinition(node);
                this.optionDefinitions.Add(definition.getValue(), definition);
            }
        }

        public question createQuestion()
        {
            return new question(this.sourceData, this.getCode());
        }

        public string getCode()
        {
            return base.getAttributeByName("code");
        }

        public string getDescription()
        {
            return base.getAttributeByName("desc");
        }

        public string getName()
        {
            return base.getAttributeByName("name");
        }

        public override string ToString()
        {
            return (this.getCode() + ": " + this.getName());
        }
    }
}

